//*****************************************
// Oscar Rodriguez Polo    c) 2007
//
// humsat_time.h
//
// class to manage Universal Time in NANOSAT
//
//*****************************************


#ifndef HUMSAT_TIME_H
#define HUMSAT_TIME_H

#include <public/edroombp.h>
#include <public/basic_types.h>

#include <iostream>

//using namespace std;

/*!
 * \class CUniTime humsat_time.h "humsat_time.h"
 * \author Oscar Rodriguez Polo
 * \brief class that manages the HUMSAT Universal Time, the reference for
 * 		  Universal Time is January 1th of 2000
*/

class CUniTime{


        uint32_t m_unitime;

        static uint32_t UniTimeRef;
        static Pr_Time LocalTimeRef;

        public:

        	/**
        * \brief Init the Nano Uni Time aux variables Out of Power On mode
        */
        static void Init();



         /**
         * \brief Updates the current universal time
         * \param currentUniTime current unitime
		   */
        static void UpdateCurrentUniTime(uint32_t currentUniTime);


         /**
        * \brief Get Current Universal Time in Seconds
        */

        static uint32_t GetCurrentUniTimeSeconds();



        /**
        * \brief Get Universal Time in Seconds
        * \param currentUniTime current unitime
        */

        uint32_t GetUniTimeSeconds(){
        	return m_unitime;
        	//return UniTimeRef;
        }
       /**
       * \brief Extracts Year, Day, Hour, Minute and Seconds from TUniTime
		 * \param uniTime UniTime where the information is extracted
		 * \param year year to extract
		 * \param day day to extract
		 * \param hour hour to extract
		 * \param minute minute to extract
		 * \param seconds seconds to extract
		 *
		 */

        void ExtractFromUniTime(
        								 uint8_t &Year
        								, uint16_t &Day
        								, uint8_t &Hour
        								, uint8_t &Minute
        								, uint8_t &Seconds);



		/**
         * \brief Builds universal time from Year, Day, Hour, Minute and Seconds
		 * \param year year for building TUniTime
		 * \param day day for building TUniTime
		 * \param hour hour for building TUniTime
		 * \param minute minute for building TUniTime
		 * \param seconds seconds for building TUniTime
		 *
		 */

        void BuildUniTime(uint8_t year
        						, uint16_t day, uint8_t hour
        						, uint8_t minute, uint8_t seconds);


        /**
         * \brief Set this variable with  the current universal time
		 */

        void SetWithCurrentUniTime();

        /**
         * \brief Show Uni Time
		 */

        void TraceUniTime();

};


#endif
